// ref: https://blog.csdn.net/wmx843230304wmx/article/details/105914048
// ref: [GNU screen](https://www.gnu.org/software/screen/

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int open_pair_pty()
{
}

int main(int argc, char *argv[])
{
    int master, slave;

    master = getpt();
    if (master < 0) {
        printf("getpt error!\n");
        return -1;
    }

    if (grantpt(master) < 0 || unlockpt(master) < 0) {
        printf("access pty error!\n");
        return -1;
    }

    char *name = ptsname(master);
    if (name == NULL) {
        printf("ptsname error!\n");
        return -1;
    }

    slave = open(name, O_RDWR);
    if (slave < 0) {
    }
    return 0;
}
